<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./OL_SDK/include-openlayers-local.js"></script>
    <script src="./libs/gaode.js"></script>
</head>

<body>
    <div id="map">
    </div>
    <script>
        var map = new ol.Map({
            target: "map",
            layers: [gaode],
            view: new ol.View({
                projection: 'EPSG:4326',
                center: [114.30, 30.50],
                zoom: 4
            })
        })
        const style = new ol.style.Style({
            //填充色
            fill: new ol.style.Fill({
                color: 'rgba(255, 255, 255, 0.2)'
            }),
            //边线颜色
            stroke: new ol.style.Stroke({
                color: '#ffcc33',
                width: 5
            }),
            //形状
            image: new ol.style.Circle({
                radius: 7,
                fill: new ol.style.Fill({
                    color: '#ffcc33'
                })
            })
        })
        const source = new ol.source.Vector({})
        const layer = new ol.layer.Vector({
            source,
            style
        })
        map.addLayer(layer)
        fetch("./data/湖北省.json").then(res => res.json()).then(data => {
            var res = new ol.format.GeoJSON().readFeatures(data);
            console.log(res)
            source.addFeatures(res);
        })
        /* 点击的时候,只让正在点击的要素的颜色显示
        1、设置高亮图层
        2、点击获取要要素  
        2-1、清空高亮图层的数据源
        2-2、设置点击的要素到高亮图层
         */
    </script>
</body>

</html>